<%- include header %>
<%- include navbar %>
<!-- 如果是登录状态，则进入信息查询页面 -->
<% if(locals.islogin){%>
<!--按条件查询-->
<div class="container">
    <div>
        <form action="/users/search" method="post">
            姓名：<input type="text" name="s_username" id="s_username" value="" class="text"> &nbsp;&nbsp;
            电话：<input type="text" name="s_telephone" id="s_telephone" value="" onkeyup="this.value=this.value.replace(/[^\d]/g,'')"  class="text"> &nbsp;&nbsp;
            <button id="queryinfo" type="submit" class="glyphicon glyphicon-search" title="查询"></button>
        </form>
    </div>
</div>

<!--用户信息显示的表单-->
<div class="container">
<table id="table"    data-toggle="table"     data-show-export="false"     data-pagination="true"     data-click-to-select="true"    data-toolbar="#toolbar">
    <thead>
    <tr>
        <th data-field="state" data-checkbox="true"></th>
        <th>编号</th>
        <th>姓名</th>
        <th>邮箱</th>
        <th>电话</th>
        <th>操作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="/users/add" class="glyphicon glyphicon-plus" title="新增">新增</a>
        </th>
    </tr>
    </thead>
    <tbody  align="center">
        <% if (datas.length) { %>
            <% datas.forEach(function(user){ %>
            <tr >
                <td data-checkbox="false"></td>
                <td ><%= user.id %></td>
                <td ><%= user.username %></td>
                <td ><%= user.email %></td>
                <td ><%= user.telephone %></td>
                <td >
                    <div class="btn-group operation">
                        
                        <a href="/users/toUpdate/<%= user.id %>" title="修改">修改</a>
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="/users/del/<%= user.id %> ">删除</a>
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                       
                    </div>
                </td>
            </tr>
            <% }) %>
        <% } %>
    </tbody>	
</table>
</div>

<!-- <script type="text/javascript">

    $('#queryinfo').on('click',function (e) {
        // var params ={
    	// 		'username': $("#s_username").val(),
    	// 		'telephone': $("#s_telephone").val()
    	// 	};
        
        var params={};
        params.username=$("#s_username").val();
        params.telephone=$("#s_telephone").val();
        console.log(params.username);


        alert('params:'+params.username);
        $.ajax({
            url:'/users/search',//async:false,
            type:'post',
            data:params,
            dataType:'json',
            success:function (result) {
                alert('传输成功');
                //var data = $.parseJSON(result);
    			alert(result);
            },
            error:function(data, XMLHttpRequest, textStatus, errorThrown){  
                alert(data);  
                alert(XMLHttpRequest.status);  
                alert(XMLHttpRequest.readyState);  
                alert(textStatus);  
            }  
        });
    })

 </script> -->


<% }else{%>
    <!-- 否则，提示重新登陆 -->
    <div id="myAlert" class="alert alert-warning">
        <a href="#" class="close" data-dismiss="alert">&times;</a>
            <strong>警告！</strong>登陆已超时，请登陆后访问。
    </div>
        
    <script>
    $(function(){
        $(".close").click(function(){
            $("#myAlert").alert();
        });
    });
    </script>
<% }%>

<%- include footer %>